/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UTsHastaCambioObjSist.UT20RS_ConsultarDatosAcademicos2;

import Herramientas.Herramientas;
import Herramientas.Visualizacion;
import ModeloNegocio.DatosModeloNegocio;
import ModeloNegocio.src.Asistencia;
import ModeloNegocio.src.Clase;
import ModeloNegocio.src.Comision;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author ivanpianetti
 */
public class UT20_9_DetalleAsistencias extends javax.swing.JFrame {

    /**
     * Creates new form UT20_9_DetalleAsistencias
     */
    public UT20_9_DetalleAsistencias() {
        Visualizacion.setVisual(this);
        initComponents();
        jMenu1.setText(Herramientas.getNombreParaPantalla(this) + jMenu1.getText());

        DefaultTableModel model = new DefaultTableModel() {

            Class[] types = new Class[]{
                java.lang.String.class,
                java.lang.Boolean.class,
                java.lang.Boolean.class,
                java.lang.Boolean.class,
                java.lang.Object.class
            };

            @Override
            public Class getColumnClass(int columnIndex) {
                return types[columnIndex];
            }
        };

        model.addColumn("Fecha");
        model.addColumn("Presente");
        model.addColumn("Justificada");
        model.addColumn("Ausente");
        model.addColumn("Cantidad Horas");

        Comision comisionQuimica = DatosModeloNegocio.getComisionQuimicaDeMatias();
        for (Clase cl : comisionQuimica.getClase()) {
            for (Asistencia a : cl.getAsistencia()) {
                Double horas = 0.0;
                if (a.isAusente()) {
                    horas = cl.getCantidadDeHoras();
                }
                model.addRow(new Object[]{Herramientas.formatFecha(cl.getFecha()), a.getPresente(), a.getJustificada(), a.isAusente(), horas});
            }
        }
        jTextFieldNumeroTotalInasistencias.setText(DatosModeloNegocio.getNumeroTotalInasistenciasPorComisionMatias(comisionQuimica) + "");
        jTextFieldHorasTotalInasistencias.setText(DatosModeloNegocio.getHorasTotalInasistenciasPorComisionMatias(comisionQuimica) + "");
        jTextFieldMaximoPromocion.setText(comisionQuimica.getInasistenciasMaxParaPromocionar() + "");
        jTextFieldMaximasRegular.setText(comisionQuimica.getInasistenciasMaxParaRegularizar() + "");
        jTextFieldPorcentajePromocion.setText(DatosModeloNegocio.getPorcentajeAsistenciaPromocionPorComisionMatias(comisionQuimica) + "%");
        jTextFieldPorcentajeRegularizacion.setText(DatosModeloNegocio.getPorcentajeAsistenciaRegularPorComisionMatias(comisionQuimica) + "%");

        jTable1.setModel(model);

        jTextFieldNumeroTotalInasistencias.setEnabled(false);
        jTextFieldHorasTotalInasistencias.setEnabled(false);
        jTextFieldMaximoPromocion.setEnabled(false);
        jTextFieldMaximasRegular.setEnabled(false);
        jTextFieldPorcentajePromocion.setEnabled(false);
        jTextFieldPorcentajeRegularizacion.setEnabled(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldPorcentajePromocion = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jTextFieldMaximoPromocion = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldPorcentajeRegularizacion = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldMaximasRegular = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldNumeroTotalInasistencias = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldHorasTotalInasistencias = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jLabel1.setText("Para Promoción:");

        jTextFieldPorcentajePromocion.setText("--");

        jLabel2.setText("de");

        jTextFieldMaximoPromocion.setText("--");

        jLabel3.setText("inasistencias máximas");

        jLabel4.setText("Para Regularizar:");

        jTextFieldPorcentajeRegularizacion.setText("--");

        jLabel5.setText("de");

        jTextFieldMaximasRegular.setText("--");

        jLabel6.setText("inasistencias máximas");

        jLabel7.setText("Total de Inasistencias:");

        jTextFieldNumeroTotalInasistencias.setText("----");

        jLabel8.setText(":");

        jTextFieldHorasTotalInasistencias.setText("----");

        jLabel9.setText("Horas");

        jMenu1.setText("Detalle de Asistencias");
        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(22, 22, 22)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
                    .add(jLabel7)
                    .add(jLabel1)
                    .add(jLabel4))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                        .add(jTextFieldPorcentajePromocion)
                        .add(jTextFieldNumeroTotalInasistencias, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 60, Short.MAX_VALUE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jTextFieldPorcentajeRegularizacion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 60, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jLabel8)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel5))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
                    .add(jTextFieldHorasTotalInasistencias, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jTextFieldMaximoPromocion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jTextFieldMaximasRegular, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 40, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(jLabel9)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jLabel6)
                        .add(15, 15, 15))))
            .add(layout.createSequentialGroup()
                .add(14, 14, 14)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 446, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(22, 22, 22)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel7)
                    .add(jTextFieldNumeroTotalInasistencias, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel8)
                    .add(jTextFieldHorasTotalInasistencias, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel9))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 26, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextFieldPorcentajePromocion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel2)
                    .add(jTextFieldMaximoPromocion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel3)
                    .add(jLabel1))
                .add(19, 19, 19)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jTextFieldPorcentajeRegularizacion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel5)
                    .add(jTextFieldMaximasRegular, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel6)
                    .add(jLabel4))
                .add(19, 19, 19))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(UT20_9_DetalleAsistencias.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(UT20_9_DetalleAsistencias.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(UT20_9_DetalleAsistencias.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(UT20_9_DetalleAsistencias.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new UT20_9_DetalleAsistencias().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField jTextFieldHorasTotalInasistencias;
    private javax.swing.JTextField jTextFieldMaximasRegular;
    private javax.swing.JTextField jTextFieldMaximoPromocion;
    private javax.swing.JTextField jTextFieldNumeroTotalInasistencias;
    private javax.swing.JTextField jTextFieldPorcentajePromocion;
    private javax.swing.JTextField jTextFieldPorcentajeRegularizacion;
    // End of variables declaration//GEN-END:variables
}
